<template>
	<view>
		<custom-nav-sq-xcx :isBack="true" currBg="usuallyBg" :needConBlock="true">
			<block slot="content">社区列表</block>
		</custom-nav-sq-xcx>
		<view class="sqConBlock"></view>
		<view class="sqConWrap">
			<view class="gridList"
				:class="[currIndex == index ? 'active' : '']"
				v-for="(item,index) in vilageList"
				:key="index"
				@tap="selCurrTown(index,item.townName)"
			>{{item.villageName}}</view>
		</view>
	</view>
</template>

<script>
	//import { getTownData } from '@/api/mine/index.js'
	export default {
		data(){
			return{
				countyName:'',
				townName:'',
				groupId:0,
				currIndex:-1,
				vilageList:[
					{id:1,villageName:'反倒是来看发多少'},
					{id:2,villageName:'股份的价格辅导'},
					{id:2,villageName:'佛挡杀佛'}
				],
				hasDataFlag:null
			}
		},
		onLoad(option){
			// this.countyName = option.countyName;
			// this.townName = option.townName;
			// this.groupId = option.groupId;
			// this.loadGridList();
		},
		methods:{
			loadGridList(){
				let field = { county:this.countyName,town:this.townName }
				getSqGroupData(field).then(res=>{
					//console.log(res)
					this.vilageList = res.data.datas;
					this.hasDataFlag = true;
					if(this.groupId > 0){
						for(let i in this.vilageList){
							if(this.vilageList[i].groupId == this.groupId){
								this.currIndex = Number(i);
							}
						}
					}
				}).catch(err=>{
					this.hasDataFlag = false;
					console.log(err)
				})
			},
			goSelCurrVillage(index,item){
				this.currIndex = index;
				// let pages = getCurrentPages();
				// let prevPage = pages[pages.length - 2];
				// prevPage.$vm.gridName = item.villageName;
				// prevPage.$vm.groupId = item.groupId;
				// prevPage.$vm.selGridFlag = true;
				uni.navigateBack({delta:1})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: $sq-fuf;
	}
</style>
<style lang="scss" scoped>
	.gridList{
		height: 90rpx;
		line-height: 90rpx;
		font-size: 28rpx;
		padding:0 30rpx;
		background: #fff;
		color: $sq-main0;
		border-bottom: 1rpx solid #eee;
		&:nth-of-type(2n){
			background: #f0f1f2;
		}
		&.active{
			color: $pss-sq-main;
			font-weight: 600;
		}
		&:last-child{
			border-bottom: none;
		}
	}
	// page{
	// 	border-top: $comBor;
	// 	background: $pss-bg-primary;
	// }
	// @import '@/static/scss/gridList.scss';
	
</style>